import time
import datetime
 
def StringToTime(strtime):
    t_tuple = time.strptime(strtime,"%Y-%m-%d %H:%M:%S")
    return time.mktime(t_tuple)
 
def StringToTime2(strtime):
    dt = datetime.datetime.strptime(strtime,"%Y-%m-%d %H:%M:%S")
    t_tuple = dt.timetuple()
    return time.mktime(t_tuple)
 
def TimeToString(timestamp):
    t_tuple = time.localtime(timestamp)
    dt = datetime.datetime(*t_tuple[:6])
    return dt.strftime("%Y-%m-%d %H:%M:%S")
 
def GetYesterday():
    d = datetime.datetime(*time.localtime()[:6])
    t = datetime.timedelta(days=1)
    return  (d-t)
 
if __name__ == "__main__":
    timestamp = StringToTime(time.strftime("%Y-%m-%d %H:%M:%S"))
    #print ('fadsfasdf',timestamp)
 
    timestamp = StringToTime2("2010-10-20 1:2:2")
    #print (timestamp)
 
    strtime = TimeToString(float('1290186225'[0:10]+'.0'))
    print (strtime)
 
    print ('-------------------------------------------')
 
    #print (GetYesterday())
